
clear all 

//define folder global here

gl Inputs "$folder\1_Inputs"
gl Intermediate "$folder\2_Intermediate"
gl Outputs "$folder\3_Outputs"

********************************************************************************
********************************************************************************
**# TABLE G.5

use "${Intermediate}\Combined for forloops.dta", clear

keep if inlist(outcome, "earn", "empl", "eshu", "home", "move")
keep if inlist(spec, "ivac")
keep if inlist(time, "qn4n1", "qn8n1")

levelsof outcome, local(outcomes)
levelsof group, local(groups)
levelsof spec, local(specs)
levelsof time, local(times)
levelsof geo, local(geos)
levelsof item, local(items)

foreach outx in `outcomes' {
	local id1 = "`outx'"
	
	foreach grox in `groups' {
		local id2 = "`grox'"
		
		foreach spex in `specs' {
			local id3 = "`spex'"
			
			foreach timx in `times' {
				local id4 = "`timx'"
				
				foreach geox in `geos' {
					local id5 = "`geox'"
					
					foreach itex in `items' {
						local id6 = "`itex'"
		
					levelsof value if 	outcome=="`outx'" & ///
										group=="`grox'" & ///
										spec=="`spex'" & ///
										time=="`timx'" & ///
										geo=="`geox'" & ///
										item=="`itex'" , ///
						clean local(`id1'_`id2'_`id3'_`id4'_`id5'_`id6')
						di "`id1'_`id2'_`id3'_`id4'_`id5'_`id6'"
						
					}
				}
			}
		}
	}
}

				
gl x " "

texdoc init "${Outputs}/Supplementary data_Table_G5.tex", replace force
tex {\footnotesize \begin{tabular}{l c c c} \hline \toprule ///
	& Cook County & New York & Combined \\
tex & (1) & (2) & (3) \\
tex \cmidrule{2-4}

tex \textbf{\underline{Housing:}} & & & \\

tex $x ~~~Not at eviction address & `move_a_ivac_qn8n1_c_co' & `move_a_ivac_qn8n1_n_co' & `move_a_ivac_qn8n1_b_co' \\
tex 							& `move_a_ivac_qn8n1_c_se' & `move_a_ivac_qn8n1_n_se' & `move_a_ivac_qn8n1_b_se' \\
tex 							& \multicolumn{1}{c}{[`move_a_ivac_qn8n1_c_obs']} ///
								& \multicolumn{1}{c}{[`move_a_ivac_qn8n1_n_obs']} ///
								& \multicolumn{1}{c}{[`move_a_ivac_qn8n1_b_obs']} \\

tex & & & \\
tex $x ~~~Emergency shelter (1 year before filing)		& `eshu_a_ivac_qn4n1_c_co' & `eshu_a_ivac_qn4n1_n_co' & `eshu_a_ivac_qn4n1_b_co' \\
tex 							& `eshu_a_ivac_qn4n1_c_se' & `eshu_a_ivac_qn4n1_n_se' & `eshu_a_ivac_qn4n1_b_se' \\
tex 							& \multicolumn{1}{c}{[`eshu_a_ivac_qn4n1_c_obs']} ///
								& \multicolumn{1}{c}{[`eshu_a_ivac_qn4n1_n_obs']} ///
								& \multicolumn{1}{c}{[`eshu_a_ivac_qn4n1_b_obs']} \\
								
tex & & & \\
tex $x ~~~Any homelessness services (1 year before filing) & `home_a_ivac_qn4n1_c_co' & `home_a_ivac_qn4n1_n_co' & `home_a_ivac_qn4n1_b_co' \\
tex 							& `home_a_ivac_qn4n1_c_se' & `home_a_ivac_qn4n1_n_se' & `home_a_ivac_qn4n1_b_se' \\
tex 							& \multicolumn{1}{c}{[`home_a_ivac_qn4n1_c_obs']} ///
								& \multicolumn{1}{c}{[`home_a_ivac_qn4n1_n_obs']} ///
								& \multicolumn{1}{c}{[`home_a_ivac_qn4n1_b_obs']} \\


tex \midrule								
								
tex \textbf{\underline{Labor Market:}} & & & \\
tex $x ~~~Earnings 				& `earn_a_ivac_qn8n1_c_co' & `earn_a_ivac_qn8n1_n_co' & `earn_a_ivac_qn8n1_b_co' \\
tex 							& `earn_a_ivac_qn8n1_c_se' & `earn_a_ivac_qn8n1_n_se' & `earn_a_ivac_qn8n1_b_se' \\
tex 							& \multicolumn{1}{c}{[`earn_a_ivac_qn8n1_c_obs']} ///
								& \multicolumn{1}{c}{[`earn_a_ivac_qn8n1_n_obs']} ///
								& \multicolumn{1}{c}{[`earn_a_ivac_qn8n1_b_obs']} \\

tex & & & \\
tex $x ~~~Employment 			& `empl_a_ivac_qn8n1_c_co' & `empl_a_ivac_qn8n1_n_co' & `empl_a_ivac_qn8n1_b_co' \\
tex 							& `empl_a_ivac_qn8n1_c_se' & `empl_a_ivac_qn8n1_n_se' & `empl_a_ivac_qn8n1_b_se' \\
tex 							& \multicolumn{1}{c}{[`empl_a_ivac_qn8n1_c_obs']} ///
								& \multicolumn{1}{c}{[`empl_a_ivac_qn8n1_n_obs']} ///
								& \multicolumn{1}{c}{[`empl_a_ivac_qn8n1_b_obs']} \\

 
tex \bottomrule \\
tex	\end{tabular} }
texdoc close


